package io.gitee.itxinmeng.encrypt.spring.boot.autoconfigure.properties;

import cn.hutool.core.util.StrUtil;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

/**
 * @author mx
 */
@Configuration
@ConfigurationProperties("custom.encrypt")
public class EncryptProperties {
    /**
     * Rsa 需配制
     */
    private String privateKey;

    /**
     * Rsa 需配制
     */
    private String publicKey;

    /**
     * Aes 需配制
     */
    private String secret;

    private String method;

    private String charset = "UTF-8";

    private String tableName = "telesale_app_auth";

    public String getPrivateKey() {
        return privateKey;
    }

    public void setPrivateKey(String privateKey) {
        this.privateKey = privateKey;
    }

    public String getPublicKey() {
        return publicKey;
    }

    public void setPublicKey(String publicKey) {
        this.publicKey = publicKey;
    }

    public String getSecret() {
        return secret;
    }

    public void setSecret(String secret) {
        this.secret = secret;
    }

    public String getCharset() {
        return charset;
    }

    public void setCharset(String charset) {
        this.charset = charset;
    }

    public String getTableName() {
        return tableName;
    }

    public void setTableName(String tableName) {
        this.tableName = tableName;
    }

    public Boolean isRsaEnabled() {
        if(StrUtil.isNotBlank(privateKey)
                && StrUtil.isNotBlank(publicKey)){
            return Boolean.TRUE;
        }else{
            return Boolean.FALSE;
        }
    }
    public Boolean isAesEnabled() {
        if(StrUtil.isNotBlank(secret)){
            return Boolean.TRUE;
        }else{
            return Boolean.FALSE;
        }
    }

    public String getMethod() {
        return method;
    }

    public void setMethod(String method) {
        this.method = method;
    }
}
